package ui;

import javax.swing.*;
import java.awt.*;

public class LayerNext extends Layer {
    private static  Image[] NEXT_ACT;
    static {
        NEXT_ACT = new Image[7];
        for (int i = 0; i < NEXT_ACT.length; i++) {
            NEXT_ACT[i] = new ImageIcon("graphics/game/" + i + ".png").getImage();
        }
    }

    public LayerNext(int x, int y, int w, int h) {
        super(x,y,w,h);
    }
    public void paint(Graphics g){
        this.createWindow(g);
        g.setFont(new Font("黑体",Font.BOLD,20));
//        g.drawImage(NEXT_ACT[this.dto.getNext()],this.x + 32,this.y + 32 ,null);
        this.drawImageOfCenter(NEXT_ACT[this.dto.getNext()],g);

    }

    /**
     * 正中绘图
     * @param g
     */
    private  void drawImageOfCenter(Image img,Graphics g) {
        int imgW = img.getWidth(null);
        int imgH = img.getHeight(null);
        g.drawImage(img,this.x + (this.w - imgW >> 1),this.y + (this.h - imgH >> 1),null);

    }
 }
